<?php namespace Common\Model;

use Hdphp\Model\Model;

class Goodslist extends Model{
	protected $table = "goodslist";
	
	
	
	
	
	public function store(){
		//一：1.验证货品表的验证是否通过
		
		if(!$this->create()) return false;
		//2.验证商品属性表里的验证是否通过
		$attrModel = new \Common\Model\Goodssx;
		if(!$attrModel->create()){
			$this->error = $attrModel->getError();
//			return false;
		}
	    //获得商品gid
		$gid = Q('post.gid',0,'intval');
		//二：如果以上验证都通过，执行添加
		//1.往货品表里添加数据
		$this->data['goods_gid'] = $gid;
		$this->data['groupid'] = implode('|', Q('post.groupid',array()));
		$num = $this->add();
		return true;
	}
	//编辑方法
	public function edit(){
		$gid = Q('post.gid',0,'intval');
	    if(!$this->create()) return false;
	    
	    $this->data['goods_gid'] = $gid;
		$this->data['groupid'] = implode('|', Q('post.groupid',array()));
		$num = $this->save();
		return true;	   
	}
	
}